package com.loveprogrammer.model.game;


import com.loveprogrammer.model.Coin;
import com.loveprogrammer.model.goods.Equipment;
import com.loveprogrammer.model.goods.Goods;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

/**
 * @version 1.0.0
 * @description: 仓库
 * @author: eric
 * @date: 2022-08-05 17:22
 **/
public class Warehouse implements Serializable {

    /**
     * 最多200件装备
     **/
    private static final int MAX_EQUIPMENT_NUM = 200;

    /**
     * 金币
     **/
    private int goldCoin;

    /**
     * 钻石
     **/
    private int diamonds;

    /**
     * 装备
     **/
    private List<Equipment> equipmentList = new ArrayList<>();


    public Warehouse() {
    }

    public Warehouse(int goldCoin, int diamonds, List<Equipment> equipmentList) {
        this.goldCoin = goldCoin;
        this.diamonds = diamonds;
        this.equipmentList = equipmentList;
    }

    public void pickUp(List<Goods> fallingGoods) {
        for (Goods good : fallingGoods) {
            if(good instanceof Equipment){
                equipmentList.add((Equipment) good);
            }
        }
    }

    public void pickUp(Coin fallingCoin) {
        if(fallingCoin != null && (fallingCoin.getGoldCoin()>0 || fallingCoin.getDiamonds()>0)){
            this.goldCoin += fallingCoin.getGoldCoin();
            this.diamonds += fallingCoin.getDiamonds();
        }
    }

    public int getGoldCoin() {
        return goldCoin;
    }

    public void setGoldCoin(int goldCoin) {
        this.goldCoin = goldCoin;
    }

    public int getDiamonds() {
        return diamonds;
    }

    public void setDiamonds(int diamonds) {
        this.diamonds = diamonds;
    }

    public List<Equipment> getEquipmentList() {
        return equipmentList;
    }

    public void setEquipmentList(List<Equipment> equipmentList) {
        this.equipmentList = equipmentList;
    }

}
